#include "block.h"
#include <QRandomGenerator>

QVector<QVector<QPoint>> Block::shapes = {
    {{0, 0}, {1, 0}, {0, 1}, {1, 1}}, // O
    {{0, 0}, {0, 1}, {0, 2}, {0, 3}}, // I
    {{0, 0}, {1, 0}, {1, 1}, {1, 2}}, // L
    {{0, 1}, {1, 1}, {1, 0}, {1, 2}}, // T
    {{0, 0}, {1, 0}, {1, 1}, {2, 1}}, // Z
};

Block::Block() {
    shape = shapes[QRandomGenerator::global()->bounded(shapes.size())];
    position = {0, 0};
}

void Block::rotate() {
    for (QPoint &p : shape) {
        int temp = p.x();
        p.setX(-p.y());
        p.setY(temp);
    }
}
